<#-- 自定义变量方法 ----------------------------------------------------------------------------------------------->
<#assign getText=localizedTextContext.getText>
<#assign getIntText=localizedTextContext.getIntText>
<#assign getLongText=localizedTextContext.getLongText>
<#include "/view/templates/ace/ace-global.ftl">


<#-- crud ----------------------------------------------------------------------------------------------->
<#-- index -->

<#macro content id='' title='' url='' navSearch=false>
	<#assign url=url>
	<div class="main-content-inner">
			<#if navList??>
			<div class="breadcrumbs" id="breadcrumbs">			
				<ul class="breadcrumb">
					<i class="ace-icon fa fa-home home-icon"></i>
					<a href="#">Home</a>
					<#list navList as nav>
						<i class="ace-icon fa fa-angle-double-right"></i>
						<li class="active">${nav}</li>
						<#comment>
						<#if nav_index != navList?size-1>					
							<li class="active">${nav}</li>
						</#if>
						</#comment>
					</#list>
				</ul><!-- /.breadcrumb -->
			</#if>
			<#if navList?? && navSearch>
				<!-- #section:basics/content.searchbox -->
				<div class="nav-search" id="nav-search">
					<form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
								</span>
					</form>
				</div><!-- /.nav-search -->
			</#if>
   			</div>
			<div class="page-content">
				<#comment>
				<#if navList><!--只显示最后两级-->
				<div class="page-header">
					<h1>
						<#list navList as nav>
							<#if nav_index==0>
								${nav}
							<#elseif nav_index==1>
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i> ${nav}
							<#elseif nav_index gte 1 && nav_index == (navList?size-1)>
									<i class="ace-icon fa fa-angle-double-right"></i> ${nav}
								</small>
							<#else>
								<i class="ace-icon fa fa-angle-double-right"></i> ${nav}
							</#if>
						</#list>
					</h1>
				</div><!-- /.page-header -->
				</#if>
				</#comment>
				<p>
					<#nested>
				</p>
				<#if url??>
					<@row fit=true id="${id}bslist" data="url:${url}"></@row>
				</#if>
			</div><!-- /.page-content -->
	</div>
<script>
	var url = $('#${id}bslist').qdata().url;
	bfsu.list({id:'${id}',url:url});
</script>
</#macro>


<#--query -->
<#macro query queryUrl="" id='' showButton=true>
    <#if queryUrl=="">
        <#local queryUrl=url>
    </#if>
    <@row id='${id}query'>
    	<form class="form-inline" name="${id}queryForm" id="${id}queryForm" action="${queryUrl}" method="POST">
    		<p>
            <#nested/>
            <#if showButton><@button icon="search" type="success" size="sm" onclick="bfsu.query({id:'${id}'});">${getText("查询")}</@button></#if>
            </p>
        </form>
    </@row>
    <script>
    bfsu.initQuery({id:'${id}'});
    $(document).ready(function(){
	    document.onkeydown = function(e){ 
			var ev = document.all ? window.event : e; 
			if(ev.keyCode==13) { 
				bfsu.query({id:'${id}',url:'${queryUrl}'});
			} 
		} 
    });
    </script>
</#macro>

<#-- querygroup -->
<#macro querygroup inc=true type='text' title='title' name='name' value=''>
	<div class="form-group">
		<div class="input-group">
			<div class="input-group-addon">${title}：</div>
			<#nested>
		</div>
	</div>
</#macro>

<#-- 列表宏 -->
<#--
 id 区分页面不同list标识
 importTable 是否生成<table>标签
 page 后端数据封装对象名称
 islitepage 是否显示精简版分页
  -->
<#macro list id='' importTable=true page=page islitepage=false>
	<#if importTable>
		<@table>
			<#nested>
		</@table>
	<#else>
		<#nested>
	</#if>
	<#if page!="">
		<#if page.items?size gt 0>
		<#if islitepage>
		<@paginationlite id=id page=page></@paginationlite>	
		<#else>
		<@pagination id=id page=page></@pagination>
		</#if>
		<#else>
		<ol class="breadcrumb">
	  		<li>${getText("没有数据")}！</li>
		</ol>
		</#if>
	</#if>
</#macro>

<#-- pagination -->
<#macro pagination page id=''>
	<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6" style='padding-left:0px;padding-right:0px;'>
		<div class="input-group">
			<span class="input-group-addon">${getText('第')}</span>
			<input type="text" class="form-control crudpage" value="${page.currentPage}">
			<span class="input-group-addon">${getText('页每页')}</span>
			<input type="text" class="form-control crudsize" value="${page.pageSize}">
			<span class="input-group-addon">${getText('条')}</span>
			<span class="input-group-addon">${getText('共')}&nbsp;${page.totalRecord}&nbsp;${getText('条')}&nbsp;${page.totalPage}&nbsp;${getText('页')}</span>
			<button class="btn btn-info form-control" onclick="javascript:bfsu.go({id:'${id}'});">GO</button>
		</div>
	</div>
	<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" style='padding-left:0px;padding-right:0px;'>
		<div class="input-group">
		
		</div>
	</div>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6" style='padding-left:0px;padding-right:0px;'>
		<ul class="pagination" style="margin:0;">
			<#assign pagenum = page.totalPage>
			<#if pagenum gt 1>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:1});" class="crud crudfirst">
						<@bsicon icon="step-backward"/>
					</a>
				</li>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage-1}});" class="crud crudprev">
						<@bsicon icon="chevron-left"/>
					</a>
				</li>
				<#if pagenum lte 3>
					<#list 1..pagenum as pn>
						<li <#if page.currentPage == pn>class="active"</#if>>
							<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
						</li>
					</#list>
				</#if>
				<#if pagenum gt 3>
					<#if page.currentPage lt 2>
						<#list 1..pagenum as pn>
							<#if pn lt 3>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage gte 2>
						<#if page.currentPage-1 gt 0>
							<li class="disabled">
								<a href="javascript:void(0);">...</a>
							</li>
							
						</#if>
						<#list 1..pagenum as pn>
							<#if (page.currentPage-1 <= pn)&&(pn <= page.currentPage+1)>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage+1 lt pagenum>
						<li class="disabled">
							<a href="javascript:void(0);">...</a>
						</li>
					</#if>
				</#if>
				
				<li <#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage+1}});" class="crud crudnext">
						<@bsicon icon="chevron-right"/>
					</a>
				</li>
				<li	<#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.totalPage}});" class="crud crudlast" data="page:${pagenum}">
						<@bsicon icon="step-forward"/>
					</a>
				</li>
			</#if>
		</ul>
	</div>
</#macro>
<#-- 精简分页宏 -->
<#macro paginationlite page id=''>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style='padding-left:0px;padding-right:0px;'>
			<input type="hidden" class="crudpage" value="${page.currentPage}">
			<input type="hidden" class="crudsize" value="${page.pageSize}">
		<ul class="pagination pagination-sm" style="margin:0;">
			<#assign pagenum = page.totalPage>
			<#if pagenum gt 1>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:1});" class="crud crudfirst">
						<@bsicon icon="step-backward"/>
					</a>
				</li>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage-1}});" class="crud crudprev">
						<@bsicon icon="chevron-left"/>
					</a>
				</li>
				<#if pagenum lte 3>
					<#list 1..pagenum as pn>
						<li <#if page.currentPage == pn>class="active"</#if>>
							<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
						</li>
					</#list>
				</#if>
				<#if pagenum gt 3>
					<#if page.currentPage lt 2>
						<#list 1..pagenum as pn>
							<#if pn lt 3>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage gte 2>
						<#if page.currentPage-1 gt 0>
							<li class="disabled">
								<a href="javascript:void(0);">...</a>
							</li>
							
						</#if>
						<#list 1..pagenum as pn>
							<#if (page.currentPage-1 <= pn)&&(pn <= page.currentPage+1)>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage+1 lt pagenum>
						<li class="disabled">
							<a href="javascript:void(0);">...</a>
						</li>
					</#if>
				</#if>
				
				<li <#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage+1}});" class="crud crudnext">
						<@bsicon icon="chevron-right"/>
					</a>
				</li>
				<li	<#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.totalPage}});" class="crud crudlast" data="page:${pagenum}">
						<@bsicon icon="step-forward"/>
					</a>
				</li>
			</#if>
		</ul>
	</div>
</#macro>
<#-- input -->
<#macro input id='' url=''>
	<form id="${id}inputForm" name="${id}inputForm" class="form-horizontal" role="form" action="${url}">
		<#nested>
	</form>
	<script type="text/javascript">
        bfsu.initInput({id:'${id}'});
     </script>
</#macro>

